﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;

namespace DFGK_WMS.Model.Models
{
    /// <summary>
    /// 出库单明细
    /// </summary>
    public partial class TShippingOrderDetail
    {
        /// <summary>
        /// 主键
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 出库订单号
        /// </summary>
        public string OrderSn { get; set; }

        /// <summary>
        /// 单据类型
        /// </summary>
        public int? BillType { get; set; }

        /// <summary>
        /// 优先级:默认为0
        /// </summary>
        public int? Proirity { get; set; }

        /// <summary>
        /// 状态：0-新建;1-提交；2-审核通过;3-作业中;4-已完成;5-强制完成;6-失效;7-异常
        /// </summary>
        public int Status { get; set; }

        #region 徐州新增字段
        /// <summary>
        /// 经办人
        /// </summary>
        public string Agent { get; set; }

        /// <summary>
        /// 装备Id
        /// </summary>
        public int? MaterialCategoryId { get; set; }

        /// <summary>
        /// 装备名称
        /// </summary>
        public string MaterialCategoryName { get; set; }

        /// <summary>
        /// 型号规格
        /// </summary>
        public string ModelSpec { get; set; }

        /// <summary>
        /// 入库库位
        /// </summary>
        public string CellName { get; set; }

        /// <summary>
        /// 关联单号
        /// </summary>
        public string RelevanceOrderSn { get; set; }
        #endregion

        /// <summary>
        /// 库房编码
        /// </summary>
        public string WarehouseCode { get; set; }

        /// <summary>
        /// 库房名称
        /// </summary>
        public string WarehouseName { get; set; }


        /// <summary>
        /// 物料ID
        /// </summary>
        public int MaterialId { get; set; }

        /// <summary>
        /// 物料号，对应公共数据库中的物料主数据表,指定仓位出库的时候物料号允许为空
        /// </summary>
        public string MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string MaterialName { get; set; }

        /// <summary>
        /// 物料类型码
        /// </summary>
        public string MaterialTypeCode { get; set; }


        /// <summary>
        /// 质量状态
        /// </summary>
        public int? QualityState { get; set; }

        /// <summary>
        /// 计量单位编号
        /// </summary>
        public int? UnitId { get; set; }

        /// <summary>
        /// 计量单位名称
        /// </summary>
        public string UnitName { get; set; }

        /// <summary>
        /// 预期出货数量
        /// </summary>
        public decimal? Qty { get; set; }

        /// <summary>
        /// 包装数量
        /// </summary>
        public int? PackQty { get; set; }

        /// <summary>
        /// 已经下架的数量
        /// </summary>
        public decimal? PickedQty { get; set; } = 0;

        /// <summary>
        /// 已经出库完成的数量
        /// </summary>
        public decimal? ShippedQty { get; set; } = 0;

        /// <summary>
        /// 订单完成日期
        /// </summary>
        public DateTime? FinshDate { get; set; }

        /// <summary>
        /// 单据来源类型：0-手动建单；1-ERP;2-MES;3-SAP
        /// </summary>
        public int? SourceType { get; set; }

        /// <summary>
        /// 创建用户Id
        /// </summary>
        public int? CreateUserId { get; set; }

        /// <summary>
        /// 创建用户名
        /// </summary>
        public string CreateUserName { get; set; }

        /// <summary>
        /// 创建日期
        /// </summary>
        public DateTime? CreateDate { get; set; }

        /// <summary>
        /// 修改用户ID
        /// </summary>
        public int? ModifyUserId { get; set; }

        /// <summary>
        /// 修改用户
        /// </summary>
        public string ModifyUserName { get; set; }

        /// <summary>
        /// 修改日期
        /// </summary>
        public DateTime? ModifyDate { get; set; }

        /// <summary>
        /// 提交人Id
        /// </summary>
        public int? SubmitUserId { get; set; }

        /// <summary>
        /// 提交人
        /// </summary>
        public string SubmitUserName { get; set; }

        /// <summary>
        /// 提交时间
        /// </summary>
        public DateTime? SubmitDate { get; set; }

        /// <summary>
        /// 审核人Id
        /// </summary>
        public int? AuditUserId { get; set; }

        /// <summary>
        /// 审核人
        /// </summary>
        public string AuditUserName { get; set; }

        /// <summary>
        /// 审核时间
        /// </summary>
        public DateTime? AuditDate { get; set; }

        /// <summary>
        /// 采购订单行项目类型：0-无；1-L外协；2-U转储;3-正常采购
        /// </summary>
        public int? PurOrderLineType { get; set; }    


        /// <summary>
        /// 合同编号
        /// </summary>
        public string ContractNo { get; set; }

        /// <summary>
        /// 是否挂起
        /// </summary>
        public bool? IsSuspend { get; set; }

        /// <summary>
        /// 仓库Id
        /// </summary>
        public int? WarehouseId { get; set; }

        /// <summary>
        /// 是否出库核审
        /// </summary>
        public bool? IsOutOrderReview { get; set; }

        /// <summary>
        /// 是否一次出库
        /// </summary>
        public bool? IsOnceOut { get; set; }

        public Guid? OnceOutGroupGuid { get; set; }

        /// <summary>
        /// 生成厂家
        /// </summary>
        public string? ProduceFactory { get; set; }

        /// <summary>
        /// 供应商名称  现在把供应商字段当客户用
        /// </summary>
        public string? SupplierName { get; set; }

        /// <summary>
        /// 供应商Id 现在把供应商字段当客户用
        /// </summary>
        public int? SupplierId { get; set; }

        /// <summary>
        /// 托盘条码
        /// </summary>
        [NotMapped]
        public string PalletBarcode { get; set; }

        /// <summary>
        /// 当前登陆人Id
        /// </summary>
        [NotMapped]
        public int NowUserId { get; set; }

        /// <summary>
        /// 当前登陆人真实姓名
        /// </summary>
        [NotMapped]
        public string NowUserRealName { get; set; }

        /// <summary>
        /// 进度
        /// </summary>
        [NotMapped]
        public decimal? ProgressValue
        {
            get
            {
                if (PickedQty <= 0 || Qty <= 0)
                {
                    return 0;
                }

                if (Qty == 0 || Qty==null)
                {
                    return 0;
                }

                return Math.Truncate(PickedQty.GetValueOrDefault() * 1000.0M / Qty.GetValueOrDefault()) / 10;
            }
        }


        [NotMapped]
        public List<TInventory> InventoryList { get; set; }
        [NotMapped]
        public List<TShippingLockCell> LockCell { get; set; }
    }
}